package com.cardmanager.pro.repository;

import com.cardmanager.pro.pojo.CreditCardAccount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface CreditCardAccountRepository extends JpaRepository<CreditCardAccount, Long>,JpaSpecificationExecutor<CreditCardAccount>{

	@Query("select creditCardAccount from CreditCardAccount creditCardAccount where creditCardAccount.userId =:userId and creditCardAccount.creditCardNumber =:creditCardNumber")
	CreditCardAccount findByUserIdAndCreditCardNumber(@Param("userId") String userId, @Param("creditCardNumber") String creditCardNumber);

	@Query("select creditCardAccount from CreditCardAccount creditCardAccount where creditCardAccount.blance !='0'")
	List<CreditCardAccount> findCreditCardAccountByBlanceNotZero();

}
